/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gui;

import business.GpsRecord;
import data.GPSRecordTable;
import data.TrainingTable;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Date;
import java.util.List;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JLabel;

/**
 *
 * @author stana
 */
public class TrackWindow extends JDialog
{

    private java.awt.Image image;
    
    private TrainingTable trainingTable;

    public TrackWindow(Date date)
    {

        setBounds(200, 200, 500, 500);
        trainingTable=new TrainingTable();
        String locations="";
        List<GpsRecord> records=trainingTable.getGPSRecord(date);
        for(GpsRecord record:records)
        {
            locations+="|"+String.valueOf(record.lat)+","+String.valueOf(record.lng);
        }
        try//tohle nefunguje url je moc dluha pro get request
        {
            // Create a URL for the image's location
            URL url = new URL("http://maps.googleapis.com/maps/api/staticmap?sensor=false?path=color:0x0000ff|weight:5"+locations);
          

            // Get the image
            image = java.awt.Toolkit.getDefaultToolkit().getDefaultToolkit().createImage(url);
        } catch (MalformedURLException e)
        {
        } catch (IOException e)
        {
        }

        JLabel imageLabel = new JLabel(new ImageIcon(image));
        getContentPane().add(imageLabel);
    }
}
